import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 手环健康数据信息 */
export interface DeviceKidbandHealthData {
  id: number // 编号
  imei?: string // 序列号
  nfcCode?: string // NFC
  macCode?: string // MAC地址
  schoolCode?: string // 所属园区
  classId?: number // 班级ID
  studentId?: number // 学生ID
  studentName: string // 学生姓名
  recordTime: string | Dayjs // 手环统计时间
  steps?: number // 步数
  heartRate?: number // 心率
  wristTemp?: number // 腕温
  bodyTemp?: number // 体温
  sort?: number // 排序
  status?: number // 状态
}

// 手环健康数据 API
export const DeviceKidbandHealthDataApi = {
  // 查询手环健康数据分页
  getDeviceKidbandHealthDataPage: async (params: any) => {
    return await request.get({ url: `/school/device-kidband-health-data/page`, params })
  },

  // 查询手环健康数据详情
  getDeviceKidbandHealthData: async (id: number) => {
    return await request.get({ url: `/school/device-kidband-health-data/get?id=` + id })
  },

  // 新增手环健康数据
  createDeviceKidbandHealthData: async (data: DeviceKidbandHealthData) => {
    return await request.post({ url: `/school/device-kidband-health-data/create`, data })
  },

  // 修改手环健康数据
  updateDeviceKidbandHealthData: async (data: DeviceKidbandHealthData) => {
    return await request.put({ url: `/school/device-kidband-health-data/update`, data })
  },

  // 删除手环健康数据
  deleteDeviceKidbandHealthData: async (id: number) => {
    return await request.delete({ url: `/school/device-kidband-health-data/delete?id=` + id })
  },

  /** 批量删除手环健康数据 */
  deleteDeviceKidbandHealthDataList: async (ids: number[]) => {
    return await request.delete({
      url: `/school/device-kidband-health-data/delete-list?ids=${ids.join(',')}`
    })
  },

  // 导出手环健康数据 Excel
  exportDeviceKidbandHealthData: async (params) => {
    return await request.download({
      url: `/school/device-kidband-health-data/export-excel`,
      params
    })
  }
}
